﻿using System;
using System.Data;
using smp.QueryDb.Executing;
using smp.QueryDb.Structure;

namespace smp.QueryDb
{
    public interface IDbSession : IDisposable
    {
        IRawResult Query(Query query);

        IRawResultItem Load(Query query);

        IRawResultItem Load(Table table, object id);

        IPagedResult<TViewModel> Query<TViewModel>(Query<TViewModel> query) where TViewModel : class;

        TViewModel Load<TViewModel>(Query<TViewModel> query) where TViewModel : class;

        void StartTransaction();

        void StartTransaction(IsolationLevel isolationLevel);

        void CommitTransaction();

        void RollbackTransaction();

        int Insert(Insert insert);

        object InsertReturningId(Insert insert);

        int Update(Update update);

        int Delete(Delete delete);

        void Execute(Execute execute);

        IRawResult ExecuteRead(ExecuteRead executeRead);

        IPagedResult<TViewModel> ExecuteRead<TViewModel>(ExecuteRead<TViewModel> executeRead);
    }
}
